package cn.iocoder.yudao.module.trade.aftersale.vo;

import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.thirdparty.zxhx.dto.ZXHXOrderSubmitRespDTO;
import cn.iocoder.yudao.module.api.member.user.dto.MemberUserSimpleRespDTO;
import cn.iocoder.yudao.module.api.product.sku.dto.ProductPropertyValueRespDTO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "管理后台 - 售后订单分页的每一条记录 Response VO")
@Data
public class AfterSaleRespPageItemVO extends AfterSaleBaseVO {

    @Schema(description = "售后编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27630")
    private Long id;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime createTime;

    @Schema(description = "产品属性数组")
    private List<ProductPropertyValueRespDTO> properties;

    public List<ProductPropertyValueRespDTO> getProperties() {
        if (CollUtil.isEmpty(properties)){
            return List.of(ProductPropertyValueRespDTO.DEFAULT);
        }
        return properties;
    }

    @Schema(description = "用户信息")
    private MemberUserSimpleRespDTO user;

    @Schema(description = "供应方名称")
    private String supplyName;

    @Schema(description = "供应方关联订单")
    @JsonIgnore
    private String supplyRelatedOrders;

    @Schema(description = "供应方关联订单")
    private List<ZXHXOrderSubmitRespDTO> supplyRelatedOrderList;

    @SuppressWarnings("unused")
    public List<ZXHXOrderSubmitRespDTO> getSupplyRelatedOrderList() {
        if (!JsonUtils.isJson(supplyRelatedOrders)) {
            return null;
        }
        return JsonUtils.parseArray(supplyRelatedOrders, ZXHXOrderSubmitRespDTO.class);
    }

    @Schema(description = "供应方售后单号")
    private String supplyRelatedNo;

}
